package plantFitght;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class Demo extends JFrame {
    public static void main(String[] args) {
        JFrame frame = new JFrame("飞机大战");
        frame.setSize(480, 852);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        JPanel jp = new PanleDemo();
        frame.setVisible(true);
        frame.add(jp);
        try {
            Thread.sleep(200);
            jp.repaint();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


}
class PanleDemo extends JPanel {

    public void paint(Graphics g){
        super.paint(g);
        try {
            BufferedImage gb = ImageIO.read(Demo.class.getResourceAsStream("pic/background.png"));
            g.drawImage(gb,0,0,this);
            Image image = Toolkit.getDefaultToolkit().getImage(Demo.class.getResource("pic/bee.png"));
            int x = 200;
            int y = 200;
            while(x<400 && y<400){
                Thread.sleep(200);
                x++;
                y++;

            }

        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }

}